//
//  DDStatusesModel.swift
//  swift微博
//
//  Created by whitcast on 16/7/14.
//  Copyright © 2016年 whitcast. All rights reserved.
//

import UIKit

class DDStatusesModel: NSObject {
    //创建时间
    var created_at: String?
    //微博id
    var id: Int64 = 0
    //微博内容
    var text: String?
    //微博来源
    var source: String?
    //用户
    var user: DDUserModel?
    //转发数
    var reposts_count: Int = 0
    //评论数
    var comments_count: Int = 0
    //赞的数量
    var attitudes_count : Int = 0
    //被转发的原微博信息字段
    var retweeted_status : DDRetweeted_statusModel?
    //模型
    var ueserModel: DDUserModel?
    //认证会员
    var verified_type: Int = 0
    //原创的图片
    var pic_urls: [DDPicViewModel]?
    
    //字典转模型
    init(dict:[String: AnyObject]){
        super.init()
        
        setValuesForKeysWithDictionary(dict)
    }
    
    override func setValue(var value: AnyObject?, forKey key: String) {
        //判断是否是用户信息
        if key == "user" {
            user = DDUserModel.init(dict: (value as? [String: AnyObject])!)
            
        }else if(key == "retweeted_status"){
            
            retweeted_status = DDRetweeted_statusModel.init(dict: (value as? [String: AnyObject])!)
            
        }else if(key == "pic_urls"){
            //字典转模型
            let arr = value as? [[String: AnyObject]]
            
            var marr = [DDPicViewModel]()
            
            for d in arr ?? [] {
             let model = DDPicViewModel.init(dict: d)
                
                marr.append(model)
            }
            
            pic_urls = marr
            
            
        }else {
   
            super.setValue(value, forKey: key)
        }
    }
    
    override func setValue(value: AnyObject?, forUndefinedKey key: String) {
        
    }
    
    override var description: String{
        
        let  keys = ["created_at"]
        
        return dictionaryWithValuesForKeys(keys).description
    }
    
    
    }
